﻿namespace com.stifel.ProjectMgmt.GanttDashboard
{
    using System.ComponentModel;
    using System.Web.UI;
    using System.Web.UI.WebControls.WebParts;

    using Microsoft.SharePoint.WebPartPages;

    using CustomControl = GanttDashboardUserControl;

    [ToolboxItemAttribute( false )]
    public class GanttDashboard : Microsoft.SharePoint.WebPartPages.WebPart
    {
        #region Fields

        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/com.stifel.ProjectMgmt/GanttDashboard/GanttDashboardUserControl.ascx";

        #endregion Fields

        #region Properties

        [Personalizable( PersonalizationScope.Shared )]
        [WebBrowsable( true )]
        [WebDisplayName( "Show projects by due date - Default" )]
        [WebDescription( "Specifies the default setting for 'Show projects by due date?'" )]
        [SPWebCategoryName( "Custom" )]
        public bool ShowByDueDate
        {
            get;
            set;
        }

        [Personalizable( PersonalizationScope.Shared )]
        [WebBrowsable( true )]
        [WebDisplayName( "Show only projects with impact within quarter - Default" )]
        [WebDescription( "Specifies the default setting for 'Show only projects with impact within quarter?'" )]
        [SPWebCategoryName( "Custom" )]
        public bool ShowOnlyImpactedProjects
        {
            get;
            set;
        }

        #endregion Properties

        #region Methods

        protected override void CreateChildControls( )
        {
            CustomControl control = ( CustomControl ) Page.LoadControl( _ascxPath );
            control.ShowOnlyImpactedProjects = this.ShowOnlyImpactedProjects;
            control.ShowByDueDate = this.ShowByDueDate;
            Controls.Add( control );
        }

        #endregion Methods
    }
}